require(["config"],function(){
	require(["jquery","template","header"],function($,template){
		function Delist(){
			this.render();
		}
		
		Delist.prototype={
			constructor:Delist,
			//渲染列表页面数据
			render:function(){
				$.ajax("http://rap2api.taobao.org/app/mock/86896/wangyi/list")
					.done($.proxy(this.handleData,this));
			},
			//处理ajxa获取到的数据
			handleData:function(data){
				//获取使用数据
				//6
				data6={list:data.res_body.list};
//				console.log(data6);
				//渲染
				var html6=template("list_template",data6);
				$("#docSix .xuan6").prepend(html6);
				//5
				data5={list5:data.res_body.list5};
//				console.log(data5);
				var html5=template("list5_template",data5);
//				console.log(html5);
				$("#docFive .xuan5").prepend(html5);
				//添加事件监听
//				console.log(this);
				this.addListener();
			},
			addListener:function(){
//				console.log("dsahdsal");
				//添加购物车
				$("#docSix .top").on("click",".buy-btn",$.proxy(this.shopPurch,this));
			},
			shopPurch:function(event){
				var src=event.target;
//				console.log(src);
				var _top=$(src).parent();
				console.log(_top);
				// 获取当前选购商品的信息
				var title=_top.find(".prod_title").text(),
					img=_top.find(".prod_img").attr("src"),
					price=_top.find(".prod_price").text(),
					oriprice=_top.find(".prod_oriprice").text();
				var currentProduct={
//					id:$(".prod_id").text(),
					title,
					img,
					price,
					oriprice
//					amount:$("#docDetail .amount").val()
				};
				console.log(currentProduct);
			}
		}
		
		new Delist();
	});
	
});
